import Vue from 'vue'
import ElementUI from 'element-ui'
import VueEasyCm from 'vue-easycm'
import 'element-ui/lib/theme-chalk/index.css'
import App from './App.vue'
import router from './router'
import store from './store'
import directives from './js/directives'
import filters from './js/filters'
import request from './js/request'
Vue.config.productionTip = false
Vue.use(ElementUI, { size: 'small', zIndex: 3000 })
Vue.use(directives)
Vue.use(filters)
Vue.use(VueEasyCm)
Vue.prototype.$get = request.get
Vue.prototype.$post = request.post
Vue.prototype.$formData = request.formData
Vue.prototype.$download = request.download
Vue.prototype.$projectId = 100093

let token = 'cae26ebfc0a54a39b2e0da35633d19b6cd11cb19efe6457ce5c8305f32fe206a59763a247662f8ceabcbd7fb42aad4d722ccad10940e861bf6e9119b915073dfb6208e46aad29fb25c550e7b8713454bf625f1c4324f86af10b21704c36ef8a1ef1c823da59578008febdffb05b6ed343b308c8c94d6d5b480cace4bb37139f9ac7db6dd2c3596f5'
localStorage.setItem('token', token)

router.beforeEach((to, from, next) => {
    let token = localStorage.getItem('token')
    if (!token) {
        ElementUI.Message.error('登录过期，请重新登录')
        next({
            path: '/login'
        })
    } else {
        next()
    }
})

new Vue({
    router,
    store,
    render: h => h(App)
}).$mount('#app')
